<template>
  <div id="bookList">
    <!-- <ul class="list">
      <li class="bookItem" v-for="(item, index) in booksList" :key="index" @click="toDetail(item)">
        <img :src="item.image" alt="">
        <div class="content">
          <span>{{item.title}}</span>
          <span>作者: {{item.author[0]}}</span>
          <span>出版社: {{item.publisher}}</span>
        </div>
        <span class="price">{{item.price}}</span>
      </li>
    </ul>-->
  </div>
</template>

<script>
export default {
  props: {
    booksList: Array
  },
  mounted() {
    if (this.$mp) {
      this.booksList = JSON.parse(this.$mp.query.booksList);
    }
    this.booksList = this.booksList.map(item => {
      item.price = item.price.replace("CNY ", "￥ ");
      item.price = item.price.replace("USD ", "$ ");
      return item;
    });
  },

  methods: {
    toDetail(bookItem) {
      wx.navigateTo({
        url: "/pages/bookItem/main?bookItem=" + JSON.stringify(bookItem)
      });
    }
  }
};
</script>
